﻿// ToLiss Captain Right DU

#include "ND.h"
void drawND1(double x, double y, double width, double height, double size, double angle, double VOR1HL,double VOR2HL, double VOR1D, double VOR2D, double GS,double TAS,double WinV,double WinD,double hight,double Rdirection,double pitch, double VOR1B, double VOR2B)
{
	//size = 1;
	size = height / 675;
	//initgraph(900, 800, INIT_RENDERMANUAL);
	//ege_enable_aa(true);
	//setbkcolor(EGERGB(255, 255, 255));

	//double x = 190;
	//double y = 60;
	width = width * size;//525
	//height = 13.5 * 50 * size;//675

	int choice = 1;
	Rdirection = Rdirection - angle;
	//cleardevice();
	setfillcolor(EGERGB(0, 0, 0));
	setfillcolor(EGERGB(0, 0, 0));
	ege_fillrect(x, y, width, height);
	drawArc(x, y, width, height, angle, size);
	drawULine(x, y, width, height, angle, size);
	drawPlane(x, y, width, height, size);
	if ((int)VOR1HL != 0)
	{
		drawVor1(x, y, width, height, size, VOR1D, angle);
	}
	if ((int)VOR2HL != 0)
	{
		drawVor2(x, y, width, height, size, VOR2D, angle);
	}
	//drawdialFrame(x, y, width, height, size);
	//drawF(x,  y,  width,  height,  size);
    PPOS(x, y, width, height, size);
	GsTAs(x, y, width, height, size,GS,TAS,WinV,WinD);
	//drawADF1(x, y, width, height, size);
	VOR1(x, y, width, height, size, choice, VOR1HL,VOR1B,VOR2B);
	VOR2(x, y, width, height, size, choice, VOR2HL, VOR1B, VOR2B);
	
	
	//drawF(x, y, width, height, size);
	
	//drawADF2(x, y, width, height, size);
    drawDashedLinesNAV(x, y, width, height, choice, pitch);
    drawScaleBarWithPointerNAV1(x, y, width, height, hight);
   
    drawDashedLineNAV(x, y, width, height);
    printNum(x, y, width, height, angle, size, choice);
    greenLine(x, y, width, height, size, Rdirection);
    drawAirplane(x + 97 * size, y + 563 * size, -pitch * 2, 0.1 * size);
    
    
}
void drawPLAN(double x, double y, double width, double height, double current_heading,double GS,double TAS,double WinV,double WinD) {


    int choice = 1;
    double size= height / 675;
    width =width* size;
    PPOS(x, y, width, height, size);
    GsTAs(x, y, width, height, size, GS, TAS, WinV, WinD);
    drawInnerScaleAndNumbersPLAN(x, y, width, height, current_heading);
    dashedlinePLAN(x, y, width, height, choice, current_heading);
    drawInvertedTrianglesOnCirclePLAN(x, y, width, height);
    drawMovePlanePLAN(x, y, width, height, 0.7, current_heading);
    //drawPlane(x, y - 95 * height / 626.0, width, height);
    

}
void drawVOR(double x1, double y1, double width, double height,double x, double y, double r, double angle, double choice, double GS, double TAS, double WinV, double WinD, double VOR1HL, double VOR2HL, double VOR1D, double VOR2D, double Rdirection, double VOR1B, double VOR2B) {


    setrendermode(RENDER_MANUAL);
    //setbkcolor(EGERGB(0, 0, 0));
    //ege_setpattern_ellipsegradient(ege_point{ CENTER_X , CENTER_Y }, EGEACOLOR(0xFF, BLACK), 200, 100, 460, 460, EGEACOLOR(0, WHITE));
    //ege_fillrect(30, 30, 700, 700);
   // outerCircle();//外边框
    Rdirection = Rdirection - angle;
    double scaleFactor = r / 158;
    double size = height / 675;
    width = width * size;
    //current_heading = updateheading(current_heading);//数据变化模拟
    drawInnerScaleAndNumbersLS(x, y, r, scaleFactor, angle);//数字与刻度2
    dashedline(x, y, r, scaleFactor, choice, angle);
    Point(x, y, r, scaleFactor);
    drawInvertedTrianglesOnCircle(x, y, r, scaleFactor, angle);
    drawPlaneVOR(x, y, r, scaleFactor, 0.8 * scaleFactor);
    GsTAs(x1, y1, width, height, size, GS, TAS, WinV, WinD);
    VOR1(x1, y1, width, height, size, choice, VOR1HL,VOR1B,VOR2B);
    VOR2(x1, y1, width, height, size, choice, VOR2HL, VOR1B, VOR2B);
    greencube(x1, y1, width, height, size, Rdirection);


}
void drawLS(double x1,double y1,double width,double height,double x, double y, double r, double angle, double choice, double GS, double TAS, double WinV, double WinD, double VOR1HL, double VOR2HL, double VOR1D, double VOR2D, double Rdirection, double VOR1B, double VOR2B) {
    // 设置初始参数
    /*CENTER_X = 244;
    CENTER_Y = 243;
  /*  DIAL_RADIUS = 158;
    x = 200;
    y = 260;
    r = 130;
    */
    double scaleFactor = r / 158;
    double size=height / 675;
    width = width * size;
    Rdirection = Rdirection - angle;
    // 计算窗口大小
    int windowWidth = (int)(489 * scaleFactor);
    int windowHeight = (int)(626 * scaleFactor);
    setrendermode(RENDER_MANUAL);
    //setbkcolor(EGERGB(0, 0, 0));
    /* initgraph(windowWidth, windowHeight);

     */

     // double current_heading = 0;
      //int choice = 1;

      /*for (; is_run(); delay_fps(60)) {
          cleardevice();*/

          // current_heading = updateheading(current_heading);
    drawInnerScaleAndNumbers(x, y, r, scaleFactor, angle);
    dashedline(x, y, r, scaleFactor, choice, angle);
    Point(x, y, r, scaleFactor);
    drawInvertedTrianglesOnCircle(x, y, r, scaleFactor, angle);
    drawPlaneVOR(x, y, r, scaleFactor, 0.8 * scaleFactor);
    GsTAs(x1, y1, width, height, size, GS, TAS, WinV, WinD);
    VOR1(x1, y1, width, height, size, choice, VOR1HL, VOR1B, VOR2B);
    VOR2(x1, y1, width, height, size, choice, VOR2HL, VOR1B, VOR2B);
    greencube(x1, y1, width, height, size, Rdirection);

    /*  }

      closegraph();
      return 0;*/
}
void drawScaleBarWithPointerNAV1(int baseX, int baseY, int width, int height, int currentValue) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;
    currentValue = (currentValue - 10000) / 300;
    // 原ScaleBar结构体中的参数
    int barX = baseX + (int)(61 * scaleX);
    int barY = baseY + (int)(589 * scaleY);
    int barWidth = (int)(17 * scaleX);
    int barHeight = (int)(17 * scaleY);
    int minValue = 0;
    int maxValue = 500;

    const int totalScale = maxValue - minValue;
    const int visibleHeight = barHeight * 5;
    const int scaleSpacing = 1;

    int contentOffset = (currentValue - minValue) * scaleSpacing * scaleY;
    contentOffset = max(0, min(contentOffset, totalScale * scaleSpacing * scaleY - visibleHeight));

    setcolor(EGERGB(255, 255, 255));
    setfont((int)(15 * scaleX), (int)(8 * scaleY), "MS UI Gothic");
    setlinewidth(2 * scaleX);

    // 绘制刻度条边框
    ege_line(baseX + 60 * scaleX, baseY + 507 * scaleY,
        baseX + 60 * scaleX, baseY + 591 * scaleY);
    ege_line(baseX + 97 * scaleX, baseY + 508 * scaleY,
        baseX + 439 * scaleX, baseY + 508 * scaleY);

    const int startScale = contentOffset / scaleSpacing / scaleY;
    const int endScale = (contentOffset + visibleHeight) / scaleSpacing / scaleY;

    for (int i = startScale; i <= endScale; i++) {
        if (i < minValue || i > maxValue) continue;

        // 计算刻度位置时，去掉 scaleY（保持逻辑间距固定）
        int yPos = barY - (i - minValue) * scaleSpacing * scaleY + contentOffset;


        if (i % 17 == 0) {
            setlinewidth(2 * scaleX);
            ege_line(baseX + 61 * scaleX, yPos,
                baseX + 76 * scaleX, yPos);

            if (i % 2 == 0) {
                char numStr[16];
                sprintf_s(numStr, "%d", i / 34 * 8000);
                ege_outtextxy(baseX + barWidth + 10 * scaleX,
                    yPos - 8 * scaleY, numStr);
            }
        }
    }
    // 绘制黄色指针
    setcolor(EGERGB(255, 255, 0));
    setlinewidth(3 * scaleX);

    int pointerY = barY - (0 - minValue) * scaleSpacing + contentOffset;
    ege_line(barX - 5 * scaleX, pointerY, barX + 5 * scaleX, pointerY);

    // 绘制指针三角形
    int triSize = (int)(8 * scaleX);
    int points[6] = {
        barX + barWidth + 20 * scaleX, pointerY,
        barX + barWidth + 20 * scaleX + triSize, pointerY - triSize / 2,
        barX + barWidth + 20 * scaleX + triSize, pointerY + triSize / 2
    };
    fillpoly(3, points);


}
// 绕指定中心点旋转一个点
void rotatePoint(float pointX, float pointY, float centerX, float centerY, float angle, float* outX, float* outY) {
    float s = sin(angle);
    float c = cos(angle);

    // 平移至原点
    float translatedX = pointX - centerX;
    float translatedY = pointY - centerY;

    // 旋转
    float rotatedX = translatedX * c - translatedY * s;
    float rotatedY = translatedX * s + translatedY * c;

    // 平移回原位置
    *outX = rotatedX + centerX;
    *outY = rotatedY + centerY;
}

// 绘制飞机函数
void drawAirplane(float centerX, float centerY, float pitchAngle, float scale) {
    // 定义飞机原始顶点（未旋转）
    const int numPoints = 11;
    float basePoints[numPoints][2] = {
        {3 * scale,3 * scale},         // 机头上部
        {45 * scale, 3 * scale},// 机头
        {83 * scale, 59 * scale},    // 机头下部
        {280 * scale, 59 * scale},    // 机身下部
        {300 * scale, 80 * scale},    // 机尾下部
        {280 * scale, 107 * scale},   // 机尾上部
        {70 * scale, 107 * scale},    // 机身上部
        {18 * scale, 67 * scale},
        {660 * scale, 80 * scale},//8
        {600 * scale, 120 * scale},//9
         {600 * scale, 40 * scale}// 机身上部
    };

    // 创建旋转后的顶点数组
    float rotatedPoints[numPoints][2];
    float radians = pitchAngle * (M_PI / 180.0f);  // 角度转弧度

    // 旋转所有点
    for (int i = 0; i < numPoints; i++) {
        rotatePoint(
            basePoints[i][0] + centerX,
            basePoints[i][1] + centerY,
            centerX, centerY,
            radians,
            &rotatedPoints[i][0],
            &rotatedPoints[i][1]
        );
    }

    // 设置黄色并填充飞机
    setfillcolor(EGERGB(255, 255, 0));
    setcolor(EGERGB(255,255,0));
    
    // 绘制填充多边形
    int polyPoints[numPoints * 2];
    for (int i = 0; i < 8; i++) {
        polyPoints[i * 2] = (int)rotatedPoints[i][0];
        polyPoints[i * 2 + 1] = (int)rotatedPoints[i][1];
    }
    fillpoly(8, polyPoints);
    setcolor(EGERGB(64, 255, 0));
    setlinewidth(1 * scale * 10);
    ege_line(rotatedPoints[4][0], rotatedPoints[4][1] , rotatedPoints[8][0], rotatedPoints[8][1]);
    ege_line(rotatedPoints[8][0], rotatedPoints[8][1], rotatedPoints[9][0], rotatedPoints[9][1]);
    ege_line(rotatedPoints[8][0], rotatedPoints[8][1], rotatedPoints[10][0], rotatedPoints[10][1]);
    setcolor(EGERGB(255, 255, 0));
    setlinewidth(4 * scale * 10);
    ege_line(centerX - 40 * scale * 10, centerY + 10 * scale * 10, centerX - 24 * scale * 10, centerY + 10 * scale * 10);
}
void drawNAV(double x1, double y1, double width1, double height1,int baseX, int baseY, int width,int height, int choice, double heigh, double current_heading, double GS, double TAS, double WinV, double WinD, double VOR1HL, double VOR2HL, double VOR1D, double VOR2D, double Rdirection,double angle,double VOR1B, double VOR2B)
{



    setrendermode(RENDER_MANUAL);
    //setbkcolor(EGERGB(0, 0, 0));
    Rdirection = Rdirection - current_heading;
    // 计算表盘参数
    double dialRadius = width * DIAL_RADIUS_RATIO;
    double centerX = baseX + width * CENTER_X_RATIO;
    double centerY = baseY + height * CENTER_Y_RATIO;
    double size = height1 / 675;
    width1 = width1 * size;



    
    // 绘制所有组件
    drawInnerScaleAndNumbersNAV(baseX, baseY, width, height, centerX, centerY, dialRadius, current_heading);
    drawScaleBarWithPointerNAV1(baseX, baseY, width, height, heigh);
    drawDashedLinesNAV(baseX, baseY, width, height, choice, current_heading);
    drawPointsNAV(baseX, baseY, width, height);
    drawInvertedTrianglesOnCircleNAV(baseX, baseY, width, height, dialRadius, centerX, centerY);
    drawDashedLineNAV(baseX, baseY, width, height);
    dashedlineNAV(baseX, baseY, width, height, choice, current_heading);
    drawPlaneNAV(baseX, baseY, width, height);
    PPOS(x1, y1, width1, height1, size);
    GsTAs(x1, y1, width1, height1, size, GS, TAS, WinV, WinD);
    VOR1(x1, y1, width1, height1, size, choice, VOR1HL, VOR1B, VOR2B);
    VOR2(x1, y1, width1, height1, size, choice, VOR2HL, VOR1B, VOR2B);
    greenLineNAV(x1, y1, width1, height1, size, Rdirection);
    drawAirplane(x1 + 97 * size, y1 + 563 * size, -angle * 2, 0.1 * size);


}

void drawPlane(double x, double y, double width, double height, double size)
{
	ege_point points1[] = { x + width / 2 - 2 * size,y + 400 * size, // 2  400
							x + width / 2 + 2 * size,y + 400 * size,
							x + width / 2 + 2 * size,y + 415 * size,
							x + width / 2 + 27 * size,y + 415 * size,
							x + width / 2 + 27 * size,y + 418 * size,
							x + width / 2 + 2 * size,y + 418 * size,
							x + width / 2 + 2 * size,y + 443 * size,
							x + width / 2 + 12 * size,y + 443 * size,
							x + width / 2 + 12 * size,y + 446 * size,
							x + width / 2 + 2 * size,y + 446 * size,
							x + width / 2 + 2 * size,y + 451 * size,
							x + width / 2 - 2 * size,y + 451 * size,
							x + width / 2 - 2 * size,y + 446 * size,
							x + width / 2 - 12 * size,y + 446 * size,
							x + width / 2 - 12 * size,y + 443 * size,
							x + width / 2 - 2 * size,y + 443 * size,
							x + width / 2 - 2 * size,y + 418 * size,
							x + width / 2 - 27 * size,y + 418 * size,
							x + width / 2 - 27 * size,y + 415 * size,
							x + width / 2 - 2 * size,y + 415 * size };
	setfillcolor(EGERGB(255, 255, 0));
	ege_fillpoly(20, points1);
}

void drawMovePlane(double x, double y, double width, double height, double size,double angle)
{
    //圆心 x=width/2  y=y/3   r  416.5
    ege_point points1[] = { x + width / 2 +16.6207*size*sin((angle-6.9111)*PI/180),y+height/3 - 16.6207 * size * cos((angle - 6.9111) * PI / 180) , // 2  400 //15.1327  0.13216  7.5946
                            x + width / 2 + 16.6207 * size * sin((angle + 6.9111) * PI / 180),y + height / 3 - 16.6207 * size * cos((angle + 6.9111) * PI / 180),// 2  15
                            x + width / 2 + 2.5 * size * sin((angle +90-36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle + 90-36.869) * PI / 180),// 2 1.5
                            x + width / 2 + 27.0416 * size * sin((angle + 90 - 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle + 90 - 3.1798) * PI / 180), //27.0138  
                             x + width / 2 + 27.0416 * size * sin((angle + 90 + 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle + 90 + 3.1798) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle + 90 + 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle + 90 + 36.869) * PI / 180),
                             x + width / 2 + 26.57536 * size * sin((-angle  + 4.316) * PI / 180),y + height / 3 + 26.57536 * size * cos((-angle  + 4.316) * PI / 180),//26.57536   4.316
                            x + width / 2 + 29.0903 * size * sin((-angle + 24.3619) * PI / 180),y + height / 3 + 29.0903 * size * cos((-angle + 24.3619) * PI / 180),//12 443  29.0903 0.4125  24.3619
                            x + width / 2 + 31.84729 * size * sin((-angle + 22.13498) * PI / 180),y + height / 3 + 31.84729 * size * cos((-angle + 22.13498) * PI / 180), //12 446 31.84729 0.37679  22.13498
                           x + width / 2 + 29.567718 * size * sin((-angle + 3.878524) * PI / 180),y + height / 3 + 29.567718 * size * cos((-angle + 3.878524) * PI / 180),// 2  446  29.567718  0.06764133  3.878524
                           x + width / 2 + 34.55792 * size * sin((-angle + 3.31778) * PI / 180),y + height / 3 + 34.55792 * size * cos((-angle + 3.31778) * PI / 180),// 2  451  34.55792  0.0578738 3.31778
                            x + width / 2 + 34.55792 * size * sin((-angle - 3.31778) * PI / 180),y + height / 3 + 34.55792 * size * cos((-angle - 3.31778) * PI / 180),
                            x + width / 2 + 29.567718 * size * sin((-angle - 3.878524) * PI / 180),y + height / 3 + 29.567718 * size * cos((-angle - 3.878524) * PI / 180),
                             x + width / 2 + 31.84729 * size * sin((-angle - 22.13498) * PI / 180),y + height / 3 + 31.84729 * size * cos((-angle - 22.13498) * PI / 180),
                            x + width / 2 + 29.0903 * size * sin((-angle - 24.3619) * PI / 180),y + height / 3 + 29.0903 * size * cos((-angle - 24.3619) * PI / 180),
                            x + width / 2 + 26.57536 * size * sin((-angle - 4.316) * PI / 180),y + height / 3 + 26.57536 * size * cos((-angle - 4.316) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle - 90 - 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle - 90 - 36.869) * PI / 180),
                            x + width / 2 + 27.0416 * size * sin((angle - 90 - 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle - 90 - 3.1798) * PI / 180),
                           x + width / 2 + 27.0416 * size * sin((angle - 90 + 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle - 90 + 3.1798) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle - 90 + 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle - 90 + 36.869) * PI / 180) };
    setfillcolor(EGERGB(255, 255, 0));
    ege_fillpoly(20, points1);
}

void drawArc(double x, double y, double width, double height, double angle, double size)
{
	//圆心x+width/2,y+415,半径340
	setcolor(EGERGB(184, 186, 189));
	setlinewidth(2 * size);
	ege_arc(x + width / 2 - 340 * size, y + 415 * size - 340 * size, 2 * 340 * size, 2 * 340 * size, -38, -103);
	//画刻度，大刻度
	//int i = 0;
	char num[][3] = { "0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35" };
	for (int i = -360; i <= 720; i += 5)
	{
		double x1;
		double y1;
		double x2;
		double y2;
		double x3;
		double y3;
		double actual_angle = i - angle;
		if (actual_angle < 0) actual_angle += 360;
		setcolor(EGERGB(190, 190, 190));

		//LOGFONT f;

		//getfont(&f);
		//
		//f.lfHeight = 25; // 设置字体高度//45
		//f.lfWeight = 200;// 设置字体粗细//8000
		//f.lfQuality = PROOF_QUALITY;
		//f.lfPitchAndFamily = FF_DECORATIVE;
		//f.lfEscapement = -(actual_angle + 90.0) * 10;

		settextjustify(CENTER_TEXT, CENTER_TEXT);
		setbkmode(TRANSPARENT);
		int number;
		//f.lfOrientation = (actual_angle ) * 10;
		double ang1 = angle + 270;
		if (ang1 >= 360) {
			ang1 = ang1 - 360;

		}



		if (i <= ang1 + 50 && i >= ang1 - 50)
		{
			if (i % 10 == 0)
			{
				x1 = x + width / 2 + 340 * size * cos(PI / 180 * actual_angle);
				y1 = y + 415 * size + 340 * size * sin(PI / 180 * actual_angle);
				x2 = x + width / 2 + 355 * size * cos(PI / 180 * actual_angle);
				y2 = y + 415 * size + 355 * size * sin(PI / 180 * actual_angle);
				x3 = x + width / 2 + 385 * size * cos(PI / 180 * actual_angle);
				y3 = y + 415 * size + 385 * size * sin(PI / 180 * actual_angle);
				setlinewidth(3 * size);
				ege_line(x1, y1, x2, y2);
                

				number = i / 10 - 27;

				if (number < 0) {
					number = number + 36;
				}
                if (number == 0)
                {
                    setcolor(EGERGB(0, 250, 250));
                    ege_point point1[] = { x + width / 2 + 340 * size * cos(PI / 180 * (actual_angle - 0.4)),y + 415 * size + 340 * size * sin(PI / 180 * (actual_angle - 0.4)),
                                            x + width / 2 + 355 * size * cos(PI / 180 * (actual_angle - 1.5)),y + 415 * size + 355 * size * sin(PI / 180 * (actual_angle - 1.5)),
                                            x + width / 2 + 355 * size * cos(PI / 180 * (actual_angle + 1.5)),y + 415 * size + 355 * size * sin(PI / 180 * (actual_angle + 1.5)),
                                            x + width / 2 + 340 * size * cos(PI / 180 * (actual_angle + 0.4)),y + 415 * size + 340 * size * sin(PI / 180 * (actual_angle + 0.4)) };
                    setlinewidth(2*size);
                    ege_drawpoly(4, point1);
                }
                setcolor(EGERGB(190, 190, 190));
				if (i % 30 == 0)
				{
					setfont(25 * size, 15 * size, "MS UI Gothic", -(actual_angle + 90.0) * 10, 400 * size, 0, 0, 0, 0);
					ege_drawtext(num[number], x3, y3);
				}
				else
				{
					x3 = x + width / 2 + 375 * size * cos(PI / 180 * actual_angle);
					y3 = y + 415 * size + 375 * size * sin(PI / 180 * actual_angle);
					setfont(18 * size, 11 * size, "MS UI Gothic", -(actual_angle + 90.0) * 10, 400 * size, 0, 0, 0, 0);
					ege_drawtext(num[number], x3, y3);
                    
				}

			}
			else if (i % 5 == 0)
			{
				x1 = x + width / 2 + 340 * size * cos(PI / 180 * actual_angle);
				y1 = y + 415 * size + 340 * size * sin(PI / 180 * actual_angle);
				x2 = x + width / 2 + 347 * size * cos(PI / 180 * actual_angle);
				y2 = y + 415 * size + 347 * size * sin(PI / 180 * actual_angle);

				setlinewidth(3 * size);
				ege_line(x1, y1, x2, y2);
			}
            
		}

	}
}

void printNum(double x, double y, double width, double height, double angle, double size,int choice)
{
    int t = pow(2, choice );
    double num1 = 5 * t;
    double num2 = 7.5 * t;
    char str1[20];
    char str2[20];
    setfont(21 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
    setcolor(EGERGB(0, 250, 250)); //蓝色
    if (num2 == 7.5)
    {
        snprintf(str2, sizeof(str2), "%.1f", num2);
    }
    else
    {
        snprintf(str2, sizeof(str2), "%d", (int)num2);
    }
    snprintf(str1, sizeof(str1), "%d", (int)num1);

    ege_drawtext(str1, x + width / 2 + 135 * size, y + 345 * size);
    ege_drawtext(str1, x + width / 2 - 135 * size, y + 345 * size);
    ege_drawtext(str2, x + width / 2 + 215 * size, y + 300 * size);
    ege_drawtext(str2, x + width / 2 - 215 * size, y + 300 * size);
    setfont(18 * size, 8 * size, "MS UI Gothic", 0, 0, 500, 0, 0, 0, 0);
    ege_drawtext("WX ALL", x + width / 2 + 215 * size, y + 380 * size);
}
void drawULine(double x, double y, double width, double height, double angle, double size)
{
	//第二圈
	//圆心x+width/2,y+415,半径340 255
	setcolor(EGERGB(175, 175, 175));
	setlinewidth(2 * size);
	ege_arc(x + width / 2 - 255 * size, y + 415 * size - 255 * size, 2 * 255 * size, 2 * 255 * size, -10, -170);
	setcolor(EGERGB(0, 0, 0));
	setlinewidth(8 * size);
	for (int i = 0; i < 360; i = i + 4) {
		ege_line(x + width / 2, y + 415 * size, x + width / 2 + 256 * size * cos((i - angle) * PI / 180), y + 415 * size + 256 * size * sin((i - angle) * PI / 180));
	}
	//第三圈 //170
	setcolor(EGERGB(175, 175, 175));
	setlinewidth(2 * size);
	ege_arc(x + width / 2 - 170 * size, y + 415 * size - 170 * size, 2 * 170 * size, 2 * 170 * size, -10, -170);
	setcolor(EGERGB(0, 0, 0));
	setlinewidth(8 * size);

	for (int i = 0; i < 360; i = i + 6) {
		ege_line(x + width / 2, y + 415 * size, x + width / 2 + 171 * size * cos((i - angle) * PI / 180), y + 415 * size + 171 * size * sin((i - angle) * PI / 180));
	}
	//第四圈//80
	setcolor(EGERGB(175, 175, 175));
	setlinewidth(2 * size);
	ege_arc(x + width / 2 - 80 * size, y + 415 * size - 80 * size, 2 * 80 * size, 2 * 80 * size, -0, -180);
	setcolor(EGERGB(0, 0, 0));
	setlinewidth(8 * size);
	for (int i = 0; i < 360; i += 12) {
		ege_line(x + width / 2, y + 415 * size, x + width / 2 + 81 * size * cos((i - angle) * PI / 180), y + 415 * size + 81 * size * sin((i - angle) * PI / 180));
	}
}

void drawdialFrame(double x, double y, double width, double height, double size)
{
	setcolor(EGERGB(45, 52, 56));
	setlinewidth(6 * size);
	ege_line(x + width + 3 * size, y - 3 * size, x + width + 3 * size, y + height + 5 * size);
	setcolor(EGERGB(67, 75, 86));
	setlinewidth(10 * size);
	ege_line(x + width + 10 * size, y - 14 * size, x + width + 10 * size, y + height + 11 * size);
	setcolor(EGERGB(45, 52, 56));
	setlinewidth(6 * size);
	ege_line(x, y + height + 3 * size, x + width + 5 * size, y + height + 3 * size);
	setcolor(EGERGB(44, 44, 46));
	setlinewidth(1 * size);
	ege_line(x, y + height + 1 * size, x + width, y + height + 1 * size);
	setcolor(EGERGB(67, 75, 86));
	setlinewidth(8 * size);
	ege_line(x - 6 * size, y + height + 8 * size, x + width + 14 * size, y + height + 8 * size);
	setcolor(EGERGB(67, 75, 86));
	setlinewidth(6 * size);
	ege_line(x - 3 * size, y - 10 * size, x - 3 * size, y + height + 9 * size);
	setcolor(EGERGB(45, 52, 56));
	setlinewidth(6 * size);
	ege_line(x, y - 3 * size, x + width + 5 * size, y - 3 * size);
	setcolor(EGERGB(67, 75, 86));
	setlinewidth(8 * size);
	ege_line(x - 6 * size, y - 10 * size, x + width + 10 * size, y - 10 * size);
}

//模拟
double virtuel(double angle)
{
	static double  direction = 1;

	if (angle <= 0)
	{
		direction = 1;
	}
	if (angle >= 360)
	{
		direction = -1;
	}
	getch();
	return angle + direction;

}

void PPOS(double x, double y, double width, double height, double size)
{
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setbkmode(TRANSPARENT);
    setcolor(EGERGB(185, 185, 185));
    setfont(22 * size, 8 * size, "MS UI Gothic", 0, 0, 500, 0, 0, 0, 0);
    ege_drawtext("PPOS", x + 445 * size, y - 2 * size);
}
void GsTAs(double x, double y, double width, double height, double size, double GS, double TAS, double WinV, double WinD)
{
    y = y - 5*size;
    x = x - 5*size;
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setbkmode(TRANSPARENT);
    setcolor(EGERGB(255, 255, 255));
    setfont(22 * size, 8 * size, "MS UI Gothic", 0, 0, 500, 0, 0, 0, 0);
   
    GS = round(GS);
    TAS = round(TAS);
    WinV = round(WinV);
    WinD = round(WinD);
    //GS TAS
    setfont(24 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
    char strgs[20];
    char strtas[20];
    char strwinv[20];
    char strwind[20];
    snprintf(strgs, sizeof(strgs), "%d", (int)GS);
    snprintf(strtas, sizeof(strtas), "%d", (int)TAS);
    snprintf(strwinv, sizeof(strwinv), "%d", (int)WinV);
    snprintf(strwind, sizeof(strwind), "%d", (int)WinD);
    ege_drawtext("GS", x + 16 * size, y - 1 * size);
    ege_drawtext("TAS", x + 95 * size, y - 1 * size);
    ege_drawtext("/", x + 55 * size, y + 25 * size);
    //数字
   
    settextjustify(RIGHT_TEXT, TOP_TEXT);
    setcolor(EGERGB(0, 255, 0));
    setfont(23 * size, 10 * size, "Tahoma", 0, 0, 200, 0, 0, 0, 0);
    if (TAS <= 0)
    {
        setlinewidth(1 * size);
        ege_line(x + 110 * size, y + 7 * size, x + 118 * size, y + 7 * size);
        ege_line(x + 122 * size, y + 7 * size, x + 130 * size, y + 7 * size);
        ege_line(x + 134 * size, y + 7 * size, x + 142 * size, y + 7 * size);
    }
    else
    {
        ege_drawtext(strtas, x + 150 * size, y - 3 * size);
    }
    ege_drawtext(strgs, x + 70 * size, y - 3 * size);
    if (WinD <= 0)
    {
        setlinewidth(1 * size);
        ege_line(x + 8 * size, y + 32 * size, x + 16 * size, y + 32 * size);
        ege_line(x + 20 * size, y + 32 * size, x + 28 * size, y + 32 * size);
        ege_line(x + 32 * size, y + 32 * size, x + 40 * size, y + 32 * size);
    }
    else
    {

        ege_drawtext(strwind, x + 46 * size, y + 23 * size);
    }


    settextjustify(LEFT_TEXT, TOP_TEXT);
    ege_drawtext(strwinv, x + 64 * size, y + 23 * size);


}

//左vor1
void VOR1(double x, double y, double width, double height, double size, int choice, double VOR1HL, double VOR1, double VOR2)
{
	
	//Left
	//VOR1
	char vor1HL1[8];
	char vor1HL[8];

	int IVOR1HL = VOR1HL;
	int t = IVOR1HL;
	int i = 0, j = 0;

	while (IVOR1HL) {
		vor1HL1[i++] = IVOR1HL % 10 + '0';
		IVOR1HL = IVOR1HL / 10;

	}
	vor1HL1[i] = '\0';
	i = i - 1;
	while (i >= 0) {
		vor1HL[j++] = vor1HL1[i--];
	}
	vor1HL[j] = '\0';

	settextjustify(CENTER_TEXT, CENTER_TEXT);
	setbkmode(TRANSPARENT);
	setcolor(EGERGB(195, 195, 195));
	setfont(24 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("VOR1", x + 50 * size, y + 440 * size);

    //char vor1[20];
    double rounded = round(VOR1 * 10) / 10;

    // 创建字符串缓冲区，确保足够大以容纳所有可能的数字和小数点
    char buffer[100];
    // 使用snprintf确保不溢出，并格式化为两位小数
    snprintf(buffer, sizeof(buffer), "%.2f", rounded);

    // 确保小数点后第二位是零
    int len = 0;
    while (buffer[len] != '\0') {
        len++;
    }
    // 查找小数点位置
    int decimal_pos = -1;
    for (int i = 0; i < len; i++) {
        if (buffer[i] == '.') {
            decimal_pos = i;
            break;
        }
    }
    // 如果找到小数点且后面有至少两位数字
    if (decimal_pos != -1 && decimal_pos + 2 < len) {
        buffer[decimal_pos + 2] = '0';
    }

    

	//right
	setfont(21 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	setcolor(EGERGB(0, 250, 250)); //蓝色
	ege_drawtext("NM", x + 75 * size, y + 490 * size);

	if (t == 0) {
		setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext(buffer, x + 55 * size, y + 462 * size);
		setcolor(EGERGB(0, 255, 0));
		setlinewidth(1 * size);
		ege_line(x + 20 * size, y + 500 * size, x + 28 * size, y + 500 * size);
		ege_line(x + 32 * size, y + 500 * size, x + 40 * size, y + 500 * size);
		ege_drawtext(".", x + 46 * size, y + 487 * size);
		ege_line(x + 51 * size, y + 501 * size, x + 58 * size, y + 501 * size);
	}
	else {
		setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext("PEK", x + 45 * size, y + 460 * size);

		/*setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext("117.10", x + 55 * size, y + 462 * size);*/


		setlinewidth(2 * size);
		//箭头
		ege_line(x + 15 * size, y + 453 * size, x + 15 * size, y + 445 * size);
		ege_line(x + 15 * size, y + 453 * size, x + 15 * size, y + 445 * size);
		ege_line(x + 15 * size, y + 453 * size, x + 23 * size, y + 461 * size);
		ege_line(x + 15 * size, y + 453 * size, x + 7 * size, y + 461 * size);
		ege_line(x + 7 * size, y + 461.5 * size, x + 23 * size, y + 461.5 * size);
		ege_line(x + 15 * size, y + 462 * size, x + 15 * size, y + 482 * size);


		setcolor(EGERGB(0, 255, 0));
		setfont(27 * size, 10 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext(vor1HL, x + 20 * size, y + 488 * size);
	}

}

//右vor2
void VOR2(double x, double y, double width, double height, double size, int choice, double VOR2HL, double VOR1, double VOR2)
{
	
	char vor2HL1[8];
	char vor2HL[8];
	/*VOR2HL = VOR2HL * 100;*/
	int IVOR2HL = VOR2HL;
	int t = IVOR2HL;
	int i = 0, j = 0;

	while (IVOR2HL) {
		vor2HL1[i++] = IVOR2HL % 10 + '0';
		IVOR2HL = IVOR2HL / 10;

	}
	vor2HL1[i] = '\0';
	i = i - 1;
	while (i >= 0) {
		vor2HL[j++] = vor2HL1[i--];
	}
	vor2HL[j] = '\0';
    char result[50];       // 存储转换后的字符串

    // 四舍五入到小数点后一位
    double rounded1 = round(VOR2HL * 10) / 10;

    // 判断是否大于等于100
    if (fabs(rounded1) >= 20) {
        // 大于等于100时，转换为整数
        snprintf(result,sizeof(result), "%.0f", rounded1);
    }
    else {
        // 小于100时，保留一位小数
        snprintf(result, sizeof(result), "%.1f", rounded1);
    }

	settextjustify(CENTER_TEXT, CENTER_TEXT);
	setbkmode(TRANSPARENT);
    double rounded = round(VOR2 * 10) / 10;

    // 创建字符串缓冲区，确保足够大以容纳所有可能的数字和小数点
    char buffer[100];
    // 使用snprintf确保不溢出，并格式化为两位小数
    snprintf(buffer, sizeof(buffer), "%.2f", rounded);

    // 确保小数点后第二位是零
    int len = 0;
    while (buffer[len] != '\0') {
        len++;
    }
    // 查找小数点位置
    int decimal_pos = -1;
    for (int i = 0; i < len; i++) {
        if (buffer[i] == '.') {
            decimal_pos = i;
            break;
        }
    }
    // 如果找到小数点且后面有至少两位数字
    if (decimal_pos != -1 && decimal_pos + 2 < len) {
        buffer[decimal_pos + 2] = '0';
    }

	setcolor(EGERGB(195, 195, 195));
	setfont(24 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("VOR2", x + width - 50 * size, y + 440 * size);

	//right
	setfont(21 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	setcolor(EGERGB(0, 250, 250)); //蓝色
	ege_drawtext("NM", x + width - 20 * size, y + 490 * size);

	//无数据
	//海里为0
	if (t == 0) {
		setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext(buffer, x + width - 57 * size, y + 462 * size);

		setcolor(EGERGB(0, 255, 0));
		setlinewidth(1 * size);
		ege_line(x + width - 66 * size, y + 500 * size, x + width - 74 * size, y + 500 * size);
		ege_line(x + width - 54 * size, y + 500 * size, x + width - 62 * size, y + 500 * size);
		ege_drawtext(".", x + width - 50 * size, y + 487 * size);
		ege_line(x + width - 36 * size, y + 501 * size, x + width - 43 * size, y + 501 * size);
	}
	//有数据海里不为0
	else {
		setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext("SZY", x + width - 45 * size, y + 460 * size);

		/*setcolor(EGERGB(195, 195, 195));
		setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext("114.70", x + width - 57 * size, y + 462 * size);*/
		//箭头
		setlinewidth(2 * size);

		ege_line(x + width - 17 * size, y + 460 * size, x + width - 17 * size, y + 445 * size);
		ege_line(x + width - 17 * size, y + 460 * size, x + width - 9 * size, y + 470 * size);
		ege_line(x + width - 9 * size, y + 470 * size, x + width - 13 * size, y + 470 * size);
		ege_line(x + width - 13 * size, y + 470 * size, x + width - 13 * size, y + 482 * size);
		ege_line(x + width - 21 * size, y + 482 * size, x + width - 21 * size, y + 470 * size);
		ege_line(x + width - 21 * size, y + 470 * size, x + width - 25 * size, y + 468 * size);
		ege_line(x + width - 25 * size, y + 470 * size, x + width - 17 * size, y + 460 * size);
		setcolor(EGERGB(0, 255, 0));
		setfont(27 * size, 10 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
		ege_drawtext(result, x + width - 60 * size, y + 488 * size);
	}

	//左ADF1


}
void drawADF1(double x, double y, double width, double height, double size)
{
	settextjustify(CENTER_TEXT, CENTER_TEXT);
	setbkmode(TRANSPARENT);
	setcolor(EGERGB(0, 255, 0));
	setfont(24 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("ADF1", x + 50 * size, y + 440 * size);

	setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("210", x + 40 * size, y + 463 * size);
}
void drawADF2(double x, double y, double width, double height, double size)
{
	settextjustify(CENTER_TEXT, CENTER_TEXT);
	setbkmode(TRANSPARENT);
	setcolor(EGERGB(0, 255, 0));
	setfont(24 * size, 9 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("ADF2", x + width - 50 * size, y + 440 * size);

	setfont(25 * size, 8 * size, "Tahoma", 0, 0, 500, 0, 0, 0, 0);
	ege_drawtext("210", x + width - 40 * size, y + 462 * size);
}
void greenLine(double x, double y, double width, double height, double size, double Rdirection)
{

	//x + width / 2, y + 415;
    
	setcolor(EGERGB(255, 255, 0));
	setlinewidth(3 * size);
	ege_line(x + width / 2, y + 55 * size, x + width / 2, y + 85 * size);
   // y = y - 160 * size;
	setcolor(EGERGB(0, 255, 0));
	setlinewidth(2 * size);
	ege_line(x + width / 2, y + 415  * size, x + width / 2 + 339  * size * sin(Rdirection * PI / 180), y + 415* size - 339 * size * cos(Rdirection * PI / 180));
	ege_point point[] = { x + width / 2 + 339 * size * sin(Rdirection * PI / 180),y + 415 * size - 339 * size * cos(Rdirection * PI / 180),
						x + width / 2 + 333.0375 * size * sin((Rdirection + 0.8600419) * PI / 180),y + 415 * size - 333.0375 * size * cos((Rdirection + 0.8600419) * PI / 180),
						x + width / 2 + 327 * size * sin(Rdirection * PI / 180),y + 415 * size - 327 * size * cos(Rdirection * PI / 180),
						x + width / 2 + 333.0375 * size * sin((Rdirection - 0.8600419) * PI / 180),y + 415 * size - 333.0375 * size * cos((Rdirection - 0.8600419) * PI / 180),
						x + width / 2 + 339 * size * sin(Rdirection * PI / 180),y + 415 * size - 339 * size * cos(Rdirection * PI / 180) };
	ege_drawpoly(5, point);


}
void greenLineNAV(double x, double y, double width, double height, double size, double Rdirection)
{
    setcolor(EGERGB(0, 255, 0));
    setlinewidth(2 * size);
    ege_line(x + width / 2, y + (415 - 160) * size, x + width / 2 + (339 - 178) * size * sin(Rdirection * PI / 180), y + (415 - 160) * size - (339 - 178) * size * cos(Rdirection * PI / 180));
    ege_point point[] = { x + width / 2 + (339-178) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (339 - 178) * size * cos(Rdirection * PI / 180),
                        x + width / 2 + (333.0375-178) * size * sin((Rdirection + 1.8600419) * PI / 180),y + (415 - 160) * size - (333.0375-178) * size * cos((Rdirection + 1.8600419) * PI / 180),
                        x + width / 2 + (327-178) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (327-178) * size * cos(Rdirection * PI / 180),
                        x + width / 2 + (333.0375-178) * size * sin((Rdirection - 1.8600419) * PI / 180),y + (415 - 160) * size - (333.0375-178) * size * cos((Rdirection - 1.8600419) * PI / 180),
                        x + width / 2 + (339-178) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (339 - 178) * size * cos(Rdirection * PI / 180) };
    ege_drawpoly(5, point);
}
void greencube(double x, double y, double width, double height, double size, double Rdirection)
{
    setcolor(EGERGB(0, 255, 0));
    setlinewidth(2 * size);
    ege_point point[] = { x + width / 2 + (339 - 184) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (339 - 184) * size * cos(Rdirection * PI / 180),
                        x + width / 2 + (333.0375 - 184) * size * sin((Rdirection + 1.8600419) * PI / 180),y + (415 - 160) * size - (333.0375 - 184) * size * cos((Rdirection + 1.8600419) * PI / 180),
                        x + width / 2 + (327 - 180) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (327 - 184) * size * cos(Rdirection * PI / 180),
                        x + width / 2 + (333.0375 - 184) * size * sin((Rdirection - 1.8600419) * PI / 180),y + (415 - 160) * size - (333.0375 - 184) * size * cos((Rdirection - 1.8600419) * PI / 180),
                        x + width / 2 + (339 - 184) * size * sin(Rdirection * PI / 180),y + (415 - 160) * size - (339 - 184) * size * cos(Rdirection * PI / 180) };
    ege_drawpoly(5, point);
}

// 基准参数（可修改这三个值实现缩放/移动）
//double DIAL_RADIUS = 158;
//double CENTER_X = 244;
//double CENTER_Y = 243;
//
//// 比例因子
//double scaleFactor = 1.0;

void Point(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor)
{
    setcolor(EGEARGB(255, 255, 255, 255));
    setlinewidth(2.0 * scaleFactor);
    ege_enable_aa(TRUE);
    ege_circle(CENTER_X + 213 * scaleFactor, CENTER_Y - 93 * scaleFactor, 4 * scaleFactor);
    ege_circle(CENTER_X + 213 * scaleFactor, CENTER_Y - 45 * scaleFactor, 4 * scaleFactor);
    ege_circle(CENTER_X + 213 * scaleFactor, CENTER_Y + 48 * scaleFactor, 4 * scaleFactor);
    ege_circle(CENTER_X + 213 * scaleFactor, CENTER_Y + 94 * scaleFactor, 4 * scaleFactor);

    setfillcolor(EGERGB(255, 255, 255));
    setlinewidth(4.0 * scaleFactor);
    setcolor(EGERGB(255, 255, 0));
    ege_line(CENTER_X - 2 * scaleFactor, CENTER_Y - 173 * scaleFactor,
        CENTER_X - 2 * scaleFactor, CENTER_Y - 141 * scaleFactor);
    ege_line(CENTER_X + 203 * scaleFactor, CENTER_Y,
        CENTER_X + 222 * scaleFactor, CENTER_Y);
}

void drawInvertedTrianglesOnCircle(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor, double VORangle) {
    setcolor(WHITE);
    setfillcolor(WHITE);
    setlinewidth(1 * scaleFactor);

    // 三角形参数
    double triangleHeight = 8.0 * scaleFactor;
    double angleSpan = 3.0;

    for (double angle = 0; angle < 360; angle += 45) {
        double angle1 = angle - angleSpan / 2;
        double angle2 = angle + angleSpan / 2;

        double ra1 = angle1 * M_PI / 180.0;
        double ra2 = angle2 * M_PI / 180.0;
        double radCenter = angle * M_PI / 180.0;

        double x1 = CENTER_X + (DIAL_RADIUS  + triangleHeight ) * cos(ra1);
        double y1 = CENTER_Y + (DIAL_RADIUS  + triangleHeight ) * sin(ra1);
        double x2 = CENTER_X + (DIAL_RADIUS  + triangleHeight ) * cos(ra2);
        double y2 = CENTER_Y + (DIAL_RADIUS  + triangleHeight ) * sin(ra2);
        double x3 = CENTER_X + DIAL_RADIUS * cos(radCenter);
        double y3 = CENTER_Y + DIAL_RADIUS * sin(radCenter);

        ege_point points[3] = {
            { x1, y1 },
            { x2, y2 },
            { x3, y3 }
        };
        ege_fillpoly(3, points);
    }
}
void dashedline(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor, double choice, double target_heading)
{
    ege_enable_aa(TRUE);

    if (choice == 1) {
        setlinewidth(4.0 * scaleFactor);
        for (int i = 0; i < 360; i += 10) {
            double angle = (i + 90.0) * M_PI / 180.0;
            const double r_inner = DIAL_RADIUS - 85 * scaleFactor;
            const double r_outer = DIAL_RADIUS - 75 * scaleFactor;

            if (i % 3 == 0) {
                ege_line(
                    CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
                    CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
                );
            }
        }

        setcolor(EGERGB(0, 250, 250));
        setfont(18 * scaleFactor, 9 * scaleFactor, "MS UI Gothic");
        ege_outtextxy(CENTER_X - 106 * scaleFactor, CENTER_Y + 95 * scaleFactor, "5");
        ege_outtextxy(CENTER_X - 47 * scaleFactor, CENTER_Y + 42 * scaleFactor, "2.5");
    }
    else if (choice == 2) {
        setlinewidth(4.0 * scaleFactor);
        for (int i = 0; i < 360; i += 10) {
            double angle = (i + 90.0) * M_PI / 180.0;
            const double r_inner = DIAL_RADIUS - (30 + 85) * scaleFactor;
            const double r_outer = DIAL_RADIUS - (40 + 85) * scaleFactor;

            if (i % 3 == 0) {
                ege_line(
                    CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
                    CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
                );
            }
        }

        // 虚线
        setlinewidth(1.0 * scaleFactor);
        setcolor(EGERGB(255, 255, 255));
        ege_circle(CENTER_X, CENTER_Y, DIAL_RADIUS - 85 * scaleFactor);

        setlinewidth(6.0 * scaleFactor);
        setcolor(EGERGB(0, 0, 0));
        for (int i = 0; i < 360; i += 10) {
            double angle = (i - target_heading + 90.0) * M_PI / 180.0;
            const double r_inner = DIAL_RADIUS - 90 * scaleFactor;
            const double r_outer = DIAL_RADIUS - 73 * scaleFactor;

            ege_line(
                CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
                CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
            );
        }

        setcolor(EGERGB(0, 250, 250));
        setfont(17 * scaleFactor, 8 * scaleFactor, "MS UI Gothic");
        ege_outtextxy(CENTER_X - 104 * scaleFactor, CENTER_Y + 94 * scaleFactor, "10");
        ege_outtextxy(CENTER_X - 45 * scaleFactor, CENTER_Y + 39 * scaleFactor, "5");
    }
    // 其他choice情况类似修改...
    else if (choice == 3) {
        setlinewidth(4.0 * scaleFactor);
        for (int i = 0; i < 360; i += 10) {
            double angle = (i + 90.0) * M_PI / 180.0;
            const double r_inner = DIAL_RADIUS - (30 + 85) * scaleFactor;
            const double r_outer = DIAL_RADIUS - (40 + 85) * scaleFactor;

            if (i % 3 == 0) {
                ege_line(
                    CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
                    CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
                );
            }
        }

        // 虚线
        setlinewidth(1.0 * scaleFactor);
        setcolor(EGERGB(255, 255, 255));
        ege_circle(CENTER_X, CENTER_Y, DIAL_RADIUS - 85 * scaleFactor);

        setlinewidth(6.0 * scaleFactor);
        setcolor(EGERGB(0, 0, 0));
        for (int i = 0; i < 360; i += 10) {
            double angle = (i - target_heading + 90.0) * M_PI / 180.0;
            const double r_inner = DIAL_RADIUS - 90 * scaleFactor;
            const double r_outer = DIAL_RADIUS - 73 * scaleFactor;

            ege_line(
                CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
                CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
            );
        }

        setcolor(EGERGB(0, 250, 250));
        setfont(17 * scaleFactor, 8 * scaleFactor, "MS UI Gothic");
        ege_outtextxy(CENTER_X - 104 * scaleFactor, CENTER_Y + 94 * scaleFactor, "20");
        ege_outtextxy(CENTER_X - 45 * scaleFactor, CENTER_Y + 39 * scaleFactor, "10");
    }
}

void drawInnerScaleAndNumbers(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor, double target_heading) {
    ege_enable_aa(TRUE);
    setcolor(EGEARGB(255, 255, 255, 255));
    setlinewidth(2);
    ege_enable_aa(TRUE);
    
    ege_circle(CENTER_X, CENTER_Y, DIAL_RADIUS);

    // 四个点
    double angle0 = (0 - target_heading) * M_PI / 180.0;
    double angle00 = (0 - target_heading + 180) * M_PI / 180.0;
    setfillcolor(EGERGB(255, 255, 255));
    ege_fillcircle(CENTER_X + 44 * scaleFactor * cos(angle0), CENTER_Y + 44 * scaleFactor * sin(angle0), 3.5 * scaleFactor);
    ege_fillcircle(CENTER_X + 90 * scaleFactor * cos(angle0), CENTER_Y + 90 * scaleFactor * sin(angle0), 3.5 * scaleFactor);
    ege_fillcircle(CENTER_X + 44 * scaleFactor * cos(angle00), CENTER_Y + 44 * scaleFactor * sin(angle00), 3.5 * scaleFactor);
    ege_fillcircle(CENTER_X + 90 * scaleFactor * cos(angle00), CENTER_Y + 90 * scaleFactor * sin(angle00), 3.5 * scaleFactor);
   
    // 小刻度
    for (double i = 0; i < 360; i += 5.0) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = DIAL_RADIUS;
        const double r_outer = DIAL_RADIUS + 4 * scaleFactor;

        setcolor(EGEARGB(255, 255, 255, 255));
        ege_line(
            CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
            CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
        );

        // 粉色线1
        setlinewidth(1.5 * scaleFactor);
        double angle1 = (0 - target_heading + 90.0) * M_PI / 180.0;
        setcolor(EGERGB(223, 0, 223));
        const double r_outer2 = DIAL_RADIUS - 64 * scaleFactor;
        ege_line(
            CENTER_X + r_inner * cos(angle1), CENTER_Y + r_inner * sin(angle1),
            CENTER_X + r_outer2 * cos(angle1), CENTER_Y + r_outer2 * sin(angle1)
        );

        // 粉色线2
        double angle2 = (180 - target_heading + 90.0) * M_PI / 180.0;
        setcolor(EGERGB(223, 0, 223));
        ege_line(
            CENTER_X + r_inner * cos(angle2), CENTER_Y + r_inner * sin(angle2),
            CENTER_X + r_outer2 * cos(angle2), CENTER_Y + r_outer2 * sin(angle2)
        );

        // 蓝标小三角
        setcolor(EGERGB(0, 250, 250));
        double angle11 = angle2 - 7 / 2 * M_PI / 180.0;
        double angle21 = angle2 + 7 / 2 * M_PI / 180.0;

        double triangleHeight = 15 * scaleFactor;
        double x1 = CENTER_X + (DIAL_RADIUS + triangleHeight) * cos(angle11);
        double y1 = CENTER_Y + (DIAL_RADIUS + triangleHeight) * sin(angle11);
        double x2 = CENTER_X + (DIAL_RADIUS + triangleHeight) * cos(angle21);
        double y2 = CENTER_Y + (DIAL_RADIUS + triangleHeight) * sin(angle21);
        double x3 = CENTER_X + DIAL_RADIUS * cos(angle2);
        double y3 = CENTER_Y + DIAL_RADIUS * sin(angle2);

        ege_point points[3] = {
            { (int)x1, (int)y1 },
            { (int)x2, (int)y2 },
            { (int)x3, (int)y3 }
        };
        ege_line(x1, y1, x2, y2);
        ege_line(x2, y2, x3, y3);
        ege_line(x3, y3, x1, y1);

        // 粉色横线
        setcolor(EGERGB(223, 0, 223));
        angle11 = angle2 - 16 / 2 * M_PI / 180.0;
        angle21 = angle2 + 16 / 2 * M_PI / 180.0;

        triangleHeight = 26 * scaleFactor;
        x1 = CENTER_X + (DIAL_RADIUS - triangleHeight) * cos(angle11);
        y1 = CENTER_Y + (DIAL_RADIUS - triangleHeight) * sin(angle11);
        x2 = CENTER_X + (DIAL_RADIUS - triangleHeight) * cos(angle21);
        y2 = CENTER_Y + (DIAL_RADIUS - triangleHeight) * sin(angle21);

        ege_line(x1, y1, x2, y2);
    }

    // 大刻度和数字
    setlinewidth(2.0 * scaleFactor);
    setcolor(EGEARGB(255, 255, 255, 255));
    char numStr[5] = { 0 };

    for (int i = 0; i < 360; i += 10) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = DIAL_RADIUS;
        const double r_outer = DIAL_RADIUS + 8 * scaleFactor;

        ege_line(
            CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
            CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
        );

        int value = (18 + i / 10) % 36;
        if ((value < 36) && (value % 3 == 0)) {
            snprintf(numStr, sizeof(numStr), "%d", value);

            const double text_radius = DIAL_RADIUS + 26.0 * scaleFactor;
            const double textX = CENTER_X + text_radius * cos(angle);
            const double textY = CENTER_Y + text_radius * sin(angle);

            double text_rotation = (i - target_heading);
            int escapement = static_cast<int>(text_rotation * 10.0);

            setfont(
                -18.0 * scaleFactor,
                0.0,
                L"MS UI Gothic",
                1800 - escapement,
                1800 - escapement,
                FW_NORMAL,
                FALSE, FALSE, FALSE
            );

            settextjustify(CENTER_TEXT, CENTER_TEXT);
            ege_drawtext(numStr, textX, textY);
        }
    }
}



void drawPlaneVOR(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor, double size)
{
    //// 飞机的基准偏移量（相对于圆心）
    
double offsetX = -244 * scaleFactor;  // 水平偏移
    double offsetY = -338 * scaleFactor; // 垂直偏移
    // 计算飞机的位置（基于圆心）
    double planeX = CENTER_X+ offsetX;
    double planeY = CENTER_Y+ offsetY;

    // 飞机的尺寸（基于 scaleFactor）
    double planeWidth = 489 * scaleFactor;
    //double planeHeight = 626 * scaleFactor;
    ege_point points1[] = {
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 400 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 400 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 415 * size) },
         { (int)(planeX + (planeWidth / 2 + 27 * size)), (int)(planeY + 415 * size) },
         { (int)(planeX + (planeWidth / 2 + 27 * size)), (int)(planeY + 418 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 418 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 443 * size) },
         { (int)(planeX + (planeWidth / 2 + 12 * size)), (int)(planeY + 443 * size) },
         { (int)(planeX + (planeWidth / 2 + 12 * size)), (int)(planeY + 446 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 446 * size) },
         { (int)(planeX + (planeWidth / 2 + 2 * size)), (int)(planeY + 451 * size) },
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 451 * size) },
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 446 * size) },
         { (int)(planeX + (planeWidth / 2 - 12 * size)), (int)(planeY + 446 * size) },
         { (int)(planeX + (planeWidth / 2 - 12 * size)), (int)(planeY + 443 * size) },
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 443 * size) },
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 418 * size) },
         { (int)(planeX + (planeWidth / 2 - 27 * size)), (int)(planeY + 418 * size) },
         { (int)(planeX + (planeWidth / 2 - 27 * size)), (int)(planeY + 415 * size) },
         { (int)(planeX + (planeWidth / 2 - 2 * size)), (int)(planeY + 415 * size) }
    };

    setfillcolor(EGERGB(255, 255, 0));
    ege_fillpoly(20, points1);
}

void drawLS(double x, double y, double r, double angle,double choice,double GS,double TAS,double WinV,double WinD,double VOR) {
    // 设置初始参数
    /*CENTER_X = 244;
    CENTER_Y = 243;
  /*  DIAL_RADIUS = 158;
    x = 200;
    y = 260;
    r = 130;
    */
    double scaleFactor = r / 158;

    // 计算窗口大小
    int windowWidth = (int)(489 * scaleFactor);
    int windowHeight = (int)(626 * scaleFactor);
    setrendermode(RENDER_MANUAL);
    //setbkcolor(EGERGB(0, 0, 0));
   /* initgraph(windowWidth, windowHeight);
   
    */

   // double current_heading = 0;
    //int choice = 1;

    /*for (; is_run(); delay_fps(60)) {
        cleardevice();*/

       // current_heading = updateheading(current_heading);
        drawInnerScaleAndNumbers(x, y, r, scaleFactor, angle);
        dashedline(x, y, r, scaleFactor, choice, angle);
        Point(x, y, r, scaleFactor);
        drawInvertedTrianglesOnCircle(x, y, r, scaleFactor, angle);
        drawPlaneVOR(x,y, r, scaleFactor, 0.8* scaleFactor);



  /*  }

    closegraph();
    return 0;*/
}
void drawVor1(double x,double y,double width,double height,double size,double VOR1D)
{
	setcolor(EGERGB(190, 190, 190));
	setlinewidth(2);
	ege_point point[] = {   x + width / 2,y + 76,
						    x + width / 2,y + 81,
							x + width / 2 + 3, y + 84,
							x + width / 2 - 3,y + 84,
							x + width / 2,y + 81 };
	ege_drawpoly(5, point);
}

void drawVor1(double x, double y, double width, double height, double size, double VOR1D, double angle)
{
	
	if (VOR1D - angle<70 && VOR1D - angle>-70)
	{

		double t = VOR1D;
		VOR1D = VOR1D - angle;
		setcolor(EGERGB(190, 190, 190));
		setlinewidth(2 * size);
		ege_point point[] = { x + width / 2 + 339 * size * sin(VOR1D * PI / 180),y + 415 * size - 339 * size * cos(VOR1D * PI / 180),//76
								x + width / 2 + 320 * size * sin(VOR1D * PI / 180),y + 415 * size - 320 * size * cos(VOR1D * PI / 180),//95  8 105
								x + width / 2 + 306.1045 * size * sin((VOR1D + 1.4975879) * PI / 180), y + 415 * size - 306.1045 * size * cos((VOR1D + 1.4975879) * PI / 180),//306.1045 0.026134865 1.4975879
								x + width / 2 + 306.1045 * size * sin((VOR1D - 1.4975879) * PI / 180),y + 415 * size - 306.1045 * size * cos((VOR1D - 1.4975879) * PI / 180),
								x + width / 2 + 320 * size * sin(VOR1D * PI / 180),y + 415 * size - 320 * size * cos(VOR1D * PI / 180) };
		ege_line(x + width / 2 + 306 * size * sin(VOR1D * PI / 180), y + 415 * size - 306 * size * cos(VOR1D * PI / 180), x + width / 2 + 254 * size * sin(VOR1D * PI / 180), y + 415 * size - 254 * size * cos(VOR1D * PI / 180));
		ege_drawpoly(5, point);
		VOR1D = t;
	}
	VOR1D = VOR1D + 180;
	if (VOR1D > 360)
	{
		VOR1D -= 360;
	}
	if (VOR1D - angle<70 && VOR1D - angle>-70)
	{
		setlinewidth(2 * size);
		VOR1D = VOR1D - angle;
		setcolor(EGERGB(190, 190, 190));
		ege_point point1[] = { x + width / 2 + 339 * size * sin(VOR1D * PI / 180),y + 415 * size - 339 * size * cos(VOR1D * PI / 180),
							x + width / 2 + 320 * size * sin(VOR1D * PI / 180),y + 415 * size - 320 * size * cos(VOR1D * PI / 180),
							x + width / 2 + 320.0999 * size * sin((VOR1D + 1.42808) * PI / 180),y + 415 * size - 320.0999 * size * cos((VOR1D + 1.42808) * PI / 180),//320.0999 0.02492219 1.42808
							x + width / 2 + 310 * size * sin(VOR1D * PI / 180),y + 415 * size - 310 * size * cos(VOR1D * PI / 180),
							x + width / 2 + 320.0999 * size * sin((VOR1D - 1.42808) * PI / 180),y + 415 * size - 320.0999 * size * cos((VOR1D - 1.42808) * PI / 180),
							x + width / 2 + 320 * size * sin(VOR1D * PI / 180),y + 415 * size - 320 * size * cos(VOR1D * PI / 180) };
		ege_line(x + width / 2 + 310 * size * sin(VOR1D * PI / 180), y + 415 * size - 310 * size * cos(VOR1D * PI / 180), x + width / 2 + 254 * size * sin(VOR1D * PI / 180), y + 415 * size - 254 * size * cos(VOR1D * PI / 180));
		ege_drawpoly(6, point1);
	}
}
void drawVor2(double x, double y, double width, double height, double size, double VOR2D, double angle)
{

	if (VOR2D - angle<70 && VOR2D - angle>-70)
	{
		double t = VOR2D;
		VOR2D = VOR2D - angle;
		setcolor(EGERGB(190, 190, 190));
		setlinewidth(2 * size);
		ege_point point1[] = { x + width / 2 + 254.049 * size * sin((VOR2D - 1.1277225) * PI / 180),y + 415 * size - 254.049 * size * cos((VOR2D - 1.1277225) * PI / 180), ///254.049 0.0196812 1.1277225
							x + width / 2 + 279.0447 * size * sin((VOR2D - 1.02668) * PI / 180),y + 415 * size - 279.0447 * size * cos((VOR2D - 1.02668) * PI / 180),//279.0447 0.017918 1.02668
							x + width / 2 + 279.145 * size * sin((VOR2D - 1.84761) * PI / 180),y + 415 * size - 279.145 * size * cos((VOR2D - 1.84761) * PI / 180),//279.145  0.0322413 1.84761
							x + width / 2 + 294 * size * sin(VOR2D * PI / 180),y + 415 * size - 294 * size * cos(VOR2D * PI / 180),//121
							x + width / 2 + 279.145 * size * sin((VOR2D + 1.84761) * PI / 180),y + 415 * size - 279.145 * size * cos((VOR2D + 1.84761) * PI / 180),
							x + width / 2 + 279.0447 * size * sin((VOR2D + 1.02668) * PI / 180),y + 415 * size - 279.0447 * size * cos((VOR2D + 1.02668) * PI / 180),
							x + width / 2 + 254.049 * size * sin((VOR2D + 1.1277225) * PI / 180),y + 415 * size - 254.049 * size * cos((VOR2D + 1.1277225) * PI / 180) };
		ege_line(x + width / 2 + 294 * size * sin(VOR2D * PI / 180), y + 415 * size - 294 * size * cos(VOR2D * PI / 180), x + width / 2 + 339 * size * sin(VOR2D * PI / 180), y + 415 * size - 339 * size * cos(VOR2D * PI / 180));
		ege_drawpoly(7, point1);
		VOR2D = t;
	}
	VOR2D = VOR2D + 180;
	if (VOR2D > 360)
	{
		VOR2D -= 360;
	}
	if (VOR2D - angle<70 && VOR2D - angle>-70)
	{
		VOR2D = VOR2D - angle;
		setcolor(EGERGB(190, 190, 190));
		setlinewidth(2 * size);
		ege_point point2[] = { x + width / 2 + 254.049 * size * sin((VOR2D - 1.1277225) * PI / 180),y + 415 * size - 254.049 * size * cos((VOR2D - 1.1277225) * PI / 180),
								x + width / 2 + 291.0429 * size * sin((VOR2D - 0.98436) * PI / 180),y + 415 * size - 291.0429 * size * cos((VOR2D - 0.98436) * PI / 180),//291.0429  0.0171795  0.98436
								x + width / 2 + 284 * size * sin(VOR2D * PI / 180),y + 415 * size - 284 * size * cos(VOR2D * PI / 180), //284
								x + width / 2 + 291.0429 * size * sin((VOR2D + 0.98436) * PI / 180),y + 415 * size - 291.0429 * size * cos((VOR2D + 0.98436) * PI / 180),
								x + width / 2 + 254.049 * size * sin((VOR2D + 1.1277225) * PI / 180),y + 415 * size - 254.049 * size * cos((VOR2D + 1.1277225) * PI / 180) };
		ege_line(x + width / 2 + 284 * size * sin(VOR2D * PI / 180), y + 415 * size - 284 * size * cos(VOR2D * PI / 180), x + width / 2 + 339 * size * sin(VOR2D * PI / 180), y + 415 * size - 339 * size * cos(VOR2D * PI / 180));
		ege_drawpoly(5, point2);
	}
}

//模拟覆盖
void drawF(double x, double y, double width, double height, double size)
{
	setcolor(EGERGB(255, 255, 255));
	setlinewidth(31);
	ege_line(x + width + 35, y, x + width + 35, y + height);
	ege_line(x - 23, y, x  - 23, y + height);


}
//LS
void drawInnerScaleAndNumbersLS(double CENTER_X, double CENTER_Y, double DIAL_RADIUS, double scaleFactor, double target_heading) {
    ege_enable_aa(TRUE);
    double SCALE_FACTOR = scaleFactor;
    // 四个点
    double angle0 = (0) * M_PI / 180.0;
    double angle00 = (0 + 180) * M_PI / 180.0;
    setfillcolor(EGERGB(255, 255, 255));
    setcolor(EGERGB(255, 255, 255));
    ege_circle(CENTER_X, CENTER_Y, DIAL_RADIUS);
    ege_fillcircle(CENTER_X + 44 * SCALE_FACTOR * cos(angle0), CENTER_Y + 44 * SCALE_FACTOR * sin(angle0), 3.5 * SCALE_FACTOR);
    ege_fillcircle(CENTER_X + 90 * SCALE_FACTOR * cos(angle0), CENTER_Y + 90 * SCALE_FACTOR * sin(angle0), 3.5 * SCALE_FACTOR);
    ege_fillcircle(CENTER_X + 44 * SCALE_FACTOR * cos(angle00), CENTER_Y + 44 * SCALE_FACTOR * sin(angle00), 3.5 * SCALE_FACTOR);
    ege_fillcircle(CENTER_X + 90 * SCALE_FACTOR * cos(angle00), CENTER_Y + 90 * SCALE_FACTOR * sin(angle00), 3.5 * SCALE_FACTOR);

    // 小刻度 
    for (double i = 0; i < 360; i += 5.0) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = DIAL_RADIUS;
        const double r_outer = DIAL_RADIUS + 4 * SCALE_FACTOR;

        setcolor(EGEARGB(255, 255, 255, 255));
        ege_line(
            CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
            CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
        );

        // 蓝色线1
        setlinewidth(1.5 * SCALE_FACTOR);
        double angle1 = (90.0) * M_PI / 180.0;
        setcolor(EGERGB(0, 250, 250));
        const double r_outer2 = DIAL_RADIUS - 64 * SCALE_FACTOR;
        ege_line(
            CENTER_X + r_inner * cos(angle1), CENTER_Y + r_inner * sin(angle1),
            CENTER_X + r_outer2 * cos(angle1), CENTER_Y + r_outer2 * sin(angle1)
        );

        // 蓝色线2
        double angle2 = (180 + 90.0) * M_PI / 180.0;
        ege_line(
            CENTER_X + r_inner * cos(angle2), CENTER_Y + r_inner * sin(angle2),
            CENTER_X + r_outer2 * cos(angle2), CENTER_Y + r_outer2 * sin(angle2)
        );

        // 蓝标小三角
        setcolor(EGERGB(0, 250, 250));
        double angle3 = (180 - target_heading + 90.0) * M_PI / 180.0;
        double angle11 = angle3 - 7 / 2 * M_PI / 180.0;
        double angle21 = angle3 + 7 / 2 * M_PI / 180.0;

        double triangleHeight = 15 * SCALE_FACTOR;
        double x1 = CENTER_X + (DIAL_RADIUS + triangleHeight) * cos(angle11);
        double y1 = CENTER_Y + (DIAL_RADIUS + triangleHeight) * sin(angle11);
        double x2 = CENTER_X + (DIAL_RADIUS + triangleHeight) * cos(angle21);
        double y2 = CENTER_Y + (DIAL_RADIUS + triangleHeight) * sin(angle21);
        double x3 = CENTER_X + DIAL_RADIUS * cos(angle3);
        double y3 = CENTER_Y + DIAL_RADIUS * sin(angle3);

        ege_line(x1, y1, x2, y2);
        ege_line(x2, y2, x3, y3);
        ege_line(x3, y3, x1, y1);

        // 蓝色横线
        angle11 = angle2 - 16 / 2 * M_PI / 180.0;
        angle21 = angle2 + 16 / 2 * M_PI / 180.0;

        triangleHeight = 26 * SCALE_FACTOR;
        x1 = CENTER_X + (DIAL_RADIUS - triangleHeight) * cos(angle11);
        y1 = CENTER_Y + (DIAL_RADIUS - triangleHeight) * sin(angle11);
        x2 = CENTER_X + (DIAL_RADIUS - triangleHeight) * cos(angle21);
        y2 = CENTER_Y + (DIAL_RADIUS - triangleHeight) * sin(angle21);

        ege_line(x1, y1, x2, y2);
    }

    // 大刻度和数字
    setlinewidth(2.0 * SCALE_FACTOR);
    setcolor(EGEARGB(255, 255, 255, 255));
    char numStr[5] = { 0 };

    for (int i = 0; i < 360; i += 10) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = DIAL_RADIUS;
        const double r_outer = DIAL_RADIUS + 8 * SCALE_FACTOR;

        ege_line(
            CENTER_X + r_inner * cos(angle), CENTER_Y + r_inner * sin(angle),
            CENTER_X + r_outer * cos(angle), CENTER_Y + r_outer * sin(angle)
        );

        int value = (18 + i / 10) % 36;
        if ((value < 36) && (value % 3 == 0)) {
            snprintf(numStr, sizeof(numStr), "%d", value);

            const double text_radius = DIAL_RADIUS + 26.0 * SCALE_FACTOR;
            const double textX = CENTER_X + text_radius * cos(angle);
            const double textY = CENTER_Y + text_radius * sin(angle);

            double text_rotation = (i - target_heading);
            int escapement = static_cast<int>(text_rotation * 10.0);

            setfont(
                -18.0 * SCALE_FACTOR,
                0.0,
                L"MS UI Gothic",
                1800 - escapement,
                1800 - escapement,
                FW_NORMAL,
                FALSE, FALSE, FALSE
            );

            settextjustify(CENTER_TEXT, CENTER_TEXT);
            ege_drawtext(numStr, textX, textY);
        }
    }
}


//NAV
#define M_PI 3.1415926535

// 定义表盘半径比例
#define DIAL_RADIUS_RATIO 0.323
// 定义圆心位置比例
#define CENTER_X_RATIO 0.5
#define CENTER_Y_RATIO 0.388



// 绘制白色点
void drawPointsNAV(int baseX, int baseY, int width, int height) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;

    setcolor(EGEARGB(255, 255, 255, 255));
    setlinewidth(2.0 * scaleX);
    ege_enable_aa(TRUE);
    ege_circle(baseX + 457 * scaleX, baseY + 150 * scaleY, 4 * scaleX);
    ege_circle(baseX + 457 * scaleX, baseY + 198 * scaleY, 4 * scaleX);
    ege_circle(baseX + 457 * scaleX, baseY + 291 * scaleY, 4 * scaleX);
    ege_circle(baseX + 457 * scaleX, baseY + 337 * scaleY, 4 * scaleX);

    setfillcolor(EGERGB(255, 255, 255));
    setlinewidth(4.0 * scaleX);
    setcolor(EGERGB(255, 255, 0));
    ege_line(baseX + 242 * scaleX, baseY + 70 * scaleY, baseX + 242 * scaleX, baseY + 102 * scaleY);
    ege_line(baseX + 447 * scaleX, baseY + 243 * scaleY, baseX + 466 * scaleX, baseY + 243 * scaleY);
}

// 绘制倒三角形
void drawInvertedTrianglesOnCircleNAV(int baseX, int baseY, int width, int height, double dialRadius, double centerX, double centerY) {
    double scale = width / 489.0;

    setcolor(WHITE);
    setfillcolor(WHITE);
    setlinewidth(1 * scale);

    double triangleHeight = 10.0 * scale;
    double angleSpan = 3.0;

    for (double angle = 0; angle < 360; angle += 45) {
        double angle1 = angle - angleSpan / 2;
        double angle2 = angle + angleSpan / 2;

        double ra1 = angle1 * M_PI / 180.0;
        double ra2 = angle2 * M_PI / 180.0;
        double radCenter = angle * M_PI / 180.0;

        double x1 = centerX + (dialRadius + triangleHeight) * cos(ra1);
        double y1 = centerY + (dialRadius + triangleHeight) * sin(ra1);
        double x2 = centerX + (dialRadius + triangleHeight) * cos(ra2);
        double y2 = centerY + (dialRadius + triangleHeight) * sin(ra2);
        double x3 = centerX + dialRadius * cos(radCenter);
        double y3 = centerY + dialRadius * sin(radCenter);

        ege_point points[3] = {
            { (int)x1, (int)y1 },
            { (int)x2, (int)y2 },
            { (int)x3, (int)y3 }
        };
        ege_fillpoly(3, points);
    }
}
void dashedlineNAV(int baseX, int baseY, int width, int height, int choice, double target_heading) {
    // 计算比例因子
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;

    // 计算圆心位置和半径（基于原始比例）
    double centerX = baseX + width * 0.5;  // 原始中心X=244.5/489≈0.5
    double centerY = baseY + height * 0.388; // 原始中心Y=243/626≈0.388
    double dialRadius = width * 0.323; // 原始半径=158/489≈0.323

    ege_enable_aa(TRUE);
    setcolor(EGERGB(0, 250, 250));
    setfont((int)(17 * scaleX), (int)(8 * scaleY), "MS UI Gothic");
    ege_outtextxy(baseX + 56 * scaleX, baseY + 598 * scaleY, "100");
    setcolor(EGERGB(255, 255, 255));

    // 根据choice值绘制不同的刻度
    if (choice >= 1 && choice <= 6) {
        // 绘制主刻度线
        setlinewidth(4.0 * scaleX);
        setcolor(EGERGB(255, 255, 255));

        for (int i = 0; i < 360; i += 10) {
            double angle = (i + 90.0) * M_PI / 180.0;

            // 计算内径和外径（基于比例缩放）
            double r_inner = dialRadius - 85 * scaleX;
            double r_outer = dialRadius - 75 * scaleX;

            if (choice == 2) {
                r_inner = dialRadius - (30 + 85) * scaleX;
                r_outer = dialRadius - (40 + 85) * scaleX;
            }

            if (i % 3 == 0) {
                ege_line(
                    centerX + r_inner * cos(angle), centerY + r_inner * sin(angle),
                    centerX + r_outer * cos(angle), centerY + r_outer * sin(angle)
                );
            }
        }

        // 绘制虚线圆和刻度（choice >= 2时）
        if (choice >= 2) {
            setlinewidth(1.0 * scaleX);
            setcolor(EGERGB(255, 255, 255));
            ege_circle(centerX, centerY, dialRadius - 85 * scaleX);

            setlinewidth(6.0 * scaleX);
            setcolor(EGERGB(0, 0, 0));

            for (int i = 0; i < 360; i += 10) {
                double angle = (i - target_heading + 90.0) * M_PI / 180.0;

                double r_inner = dialRadius - 90 * scaleX;
                double r_outer = dialRadius - 70 * scaleX;

                ege_line(
                    centerX + r_inner * cos(angle), centerY + r_inner * sin(angle),
                    centerX + r_outer * cos(angle), centerY + r_outer * sin(angle)
                );
            }
        }
    }
}// 绘制虚线刻度
void drawDashedLinesNAV(int baseX, int baseY, int width, int height, int choice, double target_heading) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;
    choice = 3;
    ege_enable_aa(TRUE);
    setcolor(EGERGB(0, 250, 250));
    setfont((int)(17 * scaleX), (int)(8 * scaleY), "MS UI Gothic");
    ege_outtextxy(baseX + 56 * scaleX, baseY + 598 * scaleY, "100");
    setcolor(EGERGB(255, 255, 255));

    if (choice >= 1 && choice <= 6) {
        const char* texts[6][5] = {
            {" ", " ", "0", "2.5", "5"},

            {"2.5", "7.5", "0", "5", "10"},
            {"5", "15", "0", "10", "20"},
            {"10", "30", "0", "20", "40"},
            {"20", "60", "0", "40", "80"},
             { "40", "120", "0", "80", "160" }
        };

        setcolor(EGERGB(0, 250, 250));
        setfont((int)(17 * scaleX), (int)(8 * scaleY), "MS UI Gothic");
        ege_outtextxy(baseX + 181 * scaleX, baseY + 490 * scaleY, texts[choice - 1][0]);
        ege_outtextxy(baseX + 352 * scaleX, baseY + 490 * scaleY, texts[choice - 1][1]);
        ege_outtextxy(baseX + 95 * scaleX, baseY + 490 * scaleY, texts[choice - 1][2]);
        ege_outtextxy(baseX + 268 * scaleX, baseY + 490 * scaleY, texts[choice - 1][3]);
        ege_outtextxy(baseX + 436 * scaleX, baseY + 490 * scaleY, texts[choice - 1][4]);
    }
}

// 绘制内部刻度和数字
void drawInnerScaleAndNumbersNAV(int baseX, int baseY, int width, int height, double centerX, double centerY, double dialRadius, double target_heading) {
    double scale = width / 489.0;

    ege_enable_aa(TRUE);
    setcolor(EGEARGB(255, 255, 255, 255));
    setlinewidth(2 * scale);
    ege_circle(centerX, centerY, dialRadius);

    // 绘制小刻度（5°间隔）
    for (double i = 0; i < 360; i += 5.0) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = dialRadius;
        const double r_outer = dialRadius + 4 * scale;

        setcolor(EGEARGB(255, 255, 255, 255));
        ege_line(
            centerX + r_inner * cos(angle), centerY + r_inner * sin(angle),
            centerX + r_outer * cos(angle), centerY + r_outer * sin(angle)
        );
    }

    // 绘制大刻度（10°间隔）和数字
    setlinewidth(2.0 * scale);
    for (int i = 0; i < 360; i += 10) {
        double angle = (i - target_heading + 90.0) * M_PI / 180.0;
        const double r_inner = dialRadius;
        const double r_outer = dialRadius + 8 * scale;

        ege_line(
            centerX + r_inner * cos(angle), centerY + r_inner * sin(angle),
            centerX + r_outer * cos(angle), centerY + r_outer * sin(angle)
        );

        // 绘制旋转数字
        int value = (18 + i / 10) % 36;
        if ((value < 36) && (value % 3 == 0)) {
            char numStr[5];
            snprintf(numStr, sizeof(numStr), "%d", value);

            const double text_radius = dialRadius + 26.0 * scale;
            const double textX = centerX + text_radius * cos(angle);
            const double textY = centerY + text_radius * sin(angle);

            double text_rotation = (i - target_heading);
            int escapement = static_cast<int>(text_rotation * 10.0);

            setfont(
                -18.0 * scale, 0.0, L"MS UI Gothic",
                1800 - escapement, 1800 - escapement,
                FW_NORMAL, FALSE, FALSE, FALSE
            );

            settextjustify(CENTER_TEXT, CENTER_TEXT);
            ege_drawtext(numStr, textX, textY);
        }
    }
}

// 绘制刻度条和指针
// 绘制刻度条和指针
void drawScaleBarWithPointerNAV(int baseX, int baseY, int width, int height, int currentValue) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;
    currentValue = 60000 / 300;
    // 原ScaleBar结构体中的参数
    int barX = baseX + (int)(61 * scaleX);
    int barY = baseY + (int)(589 * scaleY);
    int barWidth = (int)(17 * scaleX);
    int barHeight = (int)(17 * scaleY);
    int minValue = 0;
    int maxValue = 500;

    const int totalScale = maxValue - minValue;
    const int visibleHeight = barHeight * 5;
    const int scaleSpacing = 1;

    int contentOffset = (currentValue - minValue) * scaleSpacing * scaleY;
    contentOffset = max(0, min(contentOffset, totalScale * scaleSpacing * scaleY - visibleHeight));

    setcolor(EGERGB(255, 255, 255));
    setfont((int)(15 * scaleX), (int)(8 * scaleY), "MS UI Gothic");
    setlinewidth(2 * scaleX);

    // 绘制刻度条边框
    ege_line(baseX + 60 * scaleX, baseY + 507 * scaleY,
        baseX + 60 * scaleX, baseY + 591 * scaleY);
    ege_line(baseX + 97 * scaleX, baseY + 508 * scaleY,
        baseX + 439 * scaleX, baseY + 508 * scaleY);

    const int startScale = contentOffset / scaleSpacing / scaleY;
    const int endScale = (contentOffset + visibleHeight) / scaleSpacing / scaleY;
    int num = 0;
    for (int i = startScale; i <= endScale; i++) {
        if (i < minValue || i > maxValue) continue;

        // 计算刻度位置时，去掉 scaleY（保持逻辑间距固定）
        int yPos = barY - (i - minValue) * scaleSpacing * scaleY + contentOffset;


        if (i % 17 == 0 && num < 4) {
            setlinewidth(2 * scaleX);
            ege_line(baseX + 61 * scaleX, yPos,
                baseX + 76 * scaleX, yPos);
            num++;
            if (i % 2 == 0) {
                char numStr[16];
                sprintf_s(numStr, "%d", i / 34 * 8000);
                ege_outtextxy(baseX + barWidth + 10 * scaleX,
                    yPos - 8 * scaleY, numStr);
            }
        }
    }
    //// 绘制黄色指针
    //setcolor(EGERGB(255, 255, 0));
    //setlinewidth(3 * scaleX);

    //int pointerY = barY - (0 - minValue) * scaleSpacing + contentOffset;
    //ege_line(barX - 5 * scaleX, pointerY, barX + 5 * scaleX, pointerY);

    //// 绘制指针三角形
    //int triSize = (int)(8 * scaleX);
    //int points[6] = {
    //    barX + barWidth + 20 * scaleX, pointerY,
    //    barX + barWidth + 20 * scaleX + triSize, pointerY - triSize / 2,
    //    barX + barWidth + 20 * scaleX + triSize, pointerY + triSize / 2
    //};
    //fillpoly(3, points);

    //// 绘制指针边框
    //setcolor(EGERGB(200, 200, 0));
    //setlinewidth(1 * scaleX);
    //ege_line(points[0], points[1], points[2], points[3]);
    //ege_line(points[2], points[3], points[4], points[5]);
    //ege_line(points[4], points[5], points[0], points[1]);
}
// 绘制虚线
void drawDashedLineNAV(int baseX, int baseY, int width, int height) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;

    setlinewidth(2 * scaleX);
    setcolor(EGERGB(255, 255, 255));
    ege_line(baseX + 97 * scaleX, baseY + 508 * scaleY, baseX + 439 * scaleX, baseY + 508 * scaleY);

    // 竖线
    ege_line(baseX + 97 * scaleX, baseY + 508 * scaleY, baseX + 97 * scaleX, baseY + 594 * scaleY);
    ege_line(baseX + 182 * scaleX, baseY + 508 * scaleY, baseX + 182 * scaleX, baseY + 594 * scaleY);
    ege_line(baseX + 267 * scaleX, baseY + 508 * scaleY, baseX + 267 * scaleX, baseY + 594 * scaleY);
    ege_line(baseX + 353 * scaleX, baseY + 508 * scaleY, baseX + 353 * scaleX, baseY + 594 * scaleY);
    ege_line(baseX + 438 * scaleX, baseY + 508 * scaleY, baseX + 438 * scaleX, baseY + 594 * scaleY);

    setlinewidth(7 * scaleX);
    setcolor(EGERGB(0, 0, 0));
    ege_line(baseX + 95 * scaleX, baseY + 520 * scaleY, baseX + 436 * scaleX, baseY + 520 * scaleY);
    ege_line(baseX + 95 * scaleX, baseY + 539 * scaleY, baseX + 436 * scaleX, baseY + 539 * scaleY);
    ege_line(baseX + 95 * scaleX, baseY + 557 * scaleY, baseX + 436 * scaleX, baseY + 557 * scaleY);
    ege_line(baseX + 95 * scaleX, baseY + 578 * scaleY, baseX + 436 * scaleX, baseY + 578 * scaleY);
}

// 绘制飞机
void drawPlaneNAV(int baseX, int baseY, int width, int height) {
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;
    double size = 0.8 * scaleX;
    baseY = baseY - 95 * scaleY;
    ege_point points1[] = {
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(400 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(400 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(415 * size)},
        {baseX + (int)(244 * scaleX + 27 * size), baseY + (int)(415 * size)},
        {baseX + (int)(244 * scaleX + 27 * size), baseY + (int)(418 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(418 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(443 * size)},
        {baseX + (int)(244 * scaleX + 12 * size), baseY + (int)(443 * size)},
        {baseX + (int)(244 * scaleX + 12 * size), baseY + (int)(446 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(446 * size)},
        {baseX + (int)(244 * scaleX + 2 * size), baseY + (int)(451 * size)},
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(451 * size)},
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(446 * size)},
        {baseX + (int)(244 * scaleX - 12 * size), baseY + (int)(446 * size)},
        {baseX + (int)(244 * scaleX - 12 * size), baseY + (int)(443 * size)},
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(443 * size)},
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(418 * size)},
        {baseX + (int)(244 * scaleX - 27 * size), baseY + (int)(418 * size)},
        {baseX + (int)(244 * scaleX - 27 * size), baseY + (int)(415 * size)},
        {baseX + (int)(244 * scaleX - 2 * size), baseY + (int)(415 * size)}
    };

    setfillcolor(EGERGB(255, 255, 0));
    ege_fillpoly(20, points1);
}
// 基准参数（基于489x626的原始尺寸）
const double DIAL_RADIUS_BASE = 158;
const double CENTER_X_BASE = 244;
const double CENTER_Y_BASE = 243;

void drawInvertedTrianglesOnCirclePLAN(double x, double y, double w, double h) {
    double scaleX = w / 489.0;
    double scaleY = h / 626.0;

    double centerX = x + CENTER_X_BASE * scaleX;
    double centerY = y + CENTER_Y_BASE * scaleY;
    double radius = DIAL_RADIUS_BASE * scaleX;

    ege_enable_aa(TRUE);
    setcolor(WHITE);
    setfillcolor(WHITE);
    setlinewidth(1 * scaleX);

    // 三角形参数
    double triangleHeight = -10.0 * scaleX;
    double angleSpan = 4.0;

    for (double angle = 0; angle < 360; angle += 90) {
        // 计算底部两个点的位置
        double angle1 = angle - angleSpan / 2;
        double angle2 = angle + angleSpan / 2;

        // 转换为弧度
        double ra1 = angle1 * M_PI / 180.0;
        double ra2 = angle2 * M_PI / 180.0;
        double radCenter = angle * M_PI / 180.0;

        // 计算底部两点坐标
        double x1 = centerX + (radius + triangleHeight) * cos(ra1);
        double y1 = centerY + (radius + triangleHeight) * sin(ra1);
        double x2 = centerX + (radius + triangleHeight) * cos(ra2);
        double y2 = centerY + (radius + triangleHeight) * sin(ra2);

        // 计算顶点坐标（朝圆心方向偏移）
        double x3 = centerX + radius * cos(radCenter);
        double y3 = centerY + radius * sin(radCenter);

        // 绘制三角形
        ege_point points[3] = {
            { (int)x1, (int)y1 },
            { (int)x2, (int)y2 },
            { (int)x3, (int)y3 }
        };
        ege_fillpoly(3, points);
    }
}

void dashedlinePLAN(double x, double y, double w, double h, int choice, int target_heading) {
    double scaleX = w / 489.0;
    double scaleY = h / 626.0;

    double centerX = x + CENTER_X_BASE * scaleX;
    double centerY = y + CENTER_Y_BASE * scaleY;
    double dialRadius = DIAL_RADIUS_BASE * scaleX;

    ege_enable_aa(TRUE);
    // 虚线圆
    {
        setlinewidth(3.0 * scaleX);
        setcolor(EGERGB(255, 255, 255));
        ege_circle(centerX, centerY, dialRadius - 85 * scaleX);

        setlinewidth(6.0 * scaleX);
        setcolor(EGERGB(0, 0, 0));
        for (int i = 0; i < 360; i += 10) {
            double angle = (i - target_heading + 90.0) * M_PI / 180.0;
            const double r_inner = dialRadius - 90 * scaleX;
            const double r_outer = dialRadius - 70 * scaleX;

            ege_line(
                centerX + r_inner * cos(angle), centerY + r_inner * sin(angle),
                centerX + r_outer * cos(angle), centerY + r_outer * sin(angle)
            );
        }
    }

    // 根据选择绘制不同文本
    setcolor(EGERGB(0, 250, 250));
    double fontSize = 18 * scaleX;
    setfont(fontSize, fontSize / 2, "MS UI Gothic");

    switch (choice) {
    case 1:
        ege_outtextxy(x + 138 * scaleX, y + 338 * scaleY, "5");
        ege_outtextxy(x + 197 * scaleX, y + 285 * scaleY, "2.5");
        break;
    case 2:
        ege_outtextxy(x + 140 * scaleX, y + 337 * scaleY, "10");
        ege_outtextxy(x + 199 * scaleX, y + 282 * scaleY, "5");
        break;
    case 3:
        ege_outtextxy(x + 140 * scaleX, y + 337 * scaleY, "20");
        ege_outtextxy(x + 199 * scaleX, y + 282 * scaleY, "10");
        break;
    case 4:
        ege_outtextxy(x + 140 * scaleX, y + 337 * scaleY, "40");
        ege_outtextxy(x + 199 * scaleX, y + 282 * scaleY, "20");
        break;
    case 5:
        ege_outtextxy(x + 140 * scaleX, y + 337 * scaleY, "80");
        ege_outtextxy(x + 199 * scaleX, y + 282 * scaleY, "40");
        break;
    case 6:
        ege_outtextxy(x + 140 * scaleX, y + 337 * scaleY, "160");
        ege_outtextxy(x + 199 * scaleX, y + 282 * scaleY, "80");
        break;
    }
}

void drawInnerScaleAndNumbersPLAN(double x, double y, double w, double h, double target_heading) {
    double scaleX = w / 489.0;
    double scaleY = h / 626.0;

    double dialRadius = DIAL_RADIUS_BASE * scaleX;
    double centerX = x + CENTER_X_BASE * scaleX;
    double centerY = y + CENTER_Y_BASE * scaleY;

    ege_enable_aa(TRUE);
    setcolor(EGEARGB(255, 255, 255, 255));
    setlinewidth(2 * scaleX);
    ege_circle(centerX, centerY, dialRadius);

    // 绘制N/S/W/E标记
    setcolor(EGERGB(255, 255, 255));
    double fontSize = 18 * scaleX;
    setfont(fontSize, fontSize / 2, "MS UI Gothic");

    ege_outtextxy(centerX - 5 * scaleX, y + 94 * scaleY, "N");
    ege_outtextxy(centerX - 5 * scaleX, y + 373 * scaleY, "S");
    ege_outtextxy(x + 100 * scaleX, centerY - 11 * scaleY, "W");
    ege_outtextxy(x + 381 * scaleX, centerY - 11 * scaleY, "E");
}

//void drawPlane(double x, double y, double w, double h) {
//    double scaleX = w / 489.0;
//    double scaleY = h / 626.0;
//    double size = 0.8 * scaleX;
//
//    ege_point points1[] = {
//        x + w / 2 - 2 * size, y + 400 * size,
//        x + w / 2 + 2 * size, y + 400 * size,
//        x + w / 2 + 2 * size, y + 415 * size,
//        x + w / 2 + 27 * size, y + 415 * size,
//        x + w / 2 + 27 * size, y + 418 * size,
//        x + w / 2 + 2 * size, y + 418 * size,
//        x + w / 2 + 2 * size, y + 443 * size,
//        x + w / 2 + 12 * size, y + 443 * size,
//        x + w / 2 + 12 * size, y + 446 * size,
//        x + w / 2 + 2 * size, y + 446 * size,
//        x + w / 2 + 2 * size, y + 451 * size,
//        x + w / 2 - 2 * size, y + 451 * size,
//        x + w / 2 - 2 * size, y + 446 * size,
//        x + w / 2 - 12 * size, y + 446 * size,
//        x + w / 2 - 12 * size, y + 443 * size,
//        x + w / 2 - 2 * size, y + 443 * size,
//        x + w / 2 - 2 * size, y + 418 * size,
//        x + w / 2 - 27 * size, y + 418 * size,
//        x + w / 2 - 27 * size, y + 415 * size,
//        x + w / 2 - 2 * size, y + 415 * size
//    };
//
//    setfillcolor(EGERGB(255, 255, 0));
//    ege_fillpoly(20, points1);
//}
void drawMovePlanePLAN(double x, double y, double width, double height, double size, double angle)
{
    double scaleX = width / 489.0;
    double scaleY = height / 626.0;
    y = y + 20 * scaleY;
          size = size * scaleX;
    //圆心 x=width/2  y=y/3   r  416.5
    ege_point points1[] = { x + width / 2 + 16.6207 * size * sin((angle - 6.9111) * PI / 180),y + height / 3 - 16.6207 * size * cos((angle - 6.9111) * PI / 180) , // 2  400 //15.1327  0.13216  7.5946
                            x + width / 2 + 16.6207 * size * sin((angle + 6.9111) * PI / 180),y + height / 3 - 16.6207 * size * cos((angle + 6.9111) * PI / 180),// 2  15
                            x + width / 2 + 2.5 * size * sin((angle + 90 - 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle + 90 - 36.869) * PI / 180),// 2 1.5
                            x + width / 2 + 27.0416 * size * sin((angle + 90 - 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle + 90 - 3.1798) * PI / 180), //27.0138  
                             x + width / 2 + 27.0416 * size * sin((angle + 90 + 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle + 90 + 3.1798) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle + 90 + 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle + 90 + 36.869) * PI / 180),
                             x + width / 2 + 26.57536 * size * sin((-angle + 4.316) * PI / 180),y + height / 3 + 26.57536 * size * cos((-angle + 4.316) * PI / 180),//26.57536   4.316
                            x + width / 2 + 29.0903 * size * sin((-angle + 24.3619) * PI / 180),y + height / 3 + 29.0903 * size * cos((-angle + 24.3619) * PI / 180),//12 443  29.0903 0.4125  24.3619
                            x + width / 2 + 31.84729 * size * sin((-angle + 22.13498) * PI / 180),y + height / 3 + 31.84729 * size * cos((-angle + 22.13498) * PI / 180), //12 446 31.84729 0.37679  22.13498
                           x + width / 2 + 29.567718 * size * sin((-angle + 3.878524) * PI / 180),y + height / 3 + 29.567718 * size * cos((-angle + 3.878524) * PI / 180),// 2  446  29.567718  0.06764133  3.878524
                           x + width / 2 + 34.55792 * size * sin((-angle + 3.31778) * PI / 180),y + height / 3 + 34.55792 * size * cos((-angle + 3.31778) * PI / 180),// 2  451  34.55792  0.0578738 3.31778
                            x + width / 2 + 34.55792 * size * sin((-angle - 3.31778) * PI / 180),y + height / 3 + 34.55792 * size * cos((-angle - 3.31778) * PI / 180),
                            x + width / 2 + 29.567718 * size * sin((-angle - 3.878524) * PI / 180),y + height / 3 + 29.567718 * size * cos((-angle - 3.878524) * PI / 180),
                             x + width / 2 + 31.84729 * size * sin((-angle - 22.13498) * PI / 180),y + height / 3 + 31.84729 * size * cos((-angle - 22.13498) * PI / 180),
                            x + width / 2 + 29.0903 * size * sin((-angle - 24.3619) * PI / 180),y + height / 3 + 29.0903 * size * cos((-angle - 24.3619) * PI / 180),
                            x + width / 2 + 26.57536 * size * sin((-angle - 4.316) * PI / 180),y + height / 3 + 26.57536 * size * cos((-angle - 4.316) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle - 90 - 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle - 90 - 36.869) * PI / 180),
                            x + width / 2 + 27.0416 * size * sin((angle - 90 - 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle - 90 - 3.1798) * PI / 180),
                           x + width / 2 + 27.0416 * size * sin((angle - 90 + 3.1798) * PI / 180),y + height / 3 - 27.0416 * size * cos((angle - 90 + 3.1798) * PI / 180),
                            x + width / 2 + 2.5 * size * sin((angle - 90 + 36.869) * PI / 180),y + height / 3 - 2.5 * size * cos((angle - 90 + 36.869) * PI / 180) };
    setfillcolor(EGERGB(255, 255, 0));
    ege_fillpoly(20, points1);
}



